//
//  main.cpp
//  min-cut
//
//  Created by Emanuele Vespa on 5/7/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#include <iostream>
#include "ParallelMinCut.h"



int main (int argc, const char * argv[])
{
    
   
    
    list<int> * first;
    list<int> * second;
    list<int>::iterator it;
    MultiGraph g;
    
    int dim;
    
    if( argc == 2){
        
        dim = atoi(argv[1]);
    
        g.generateMatrix(dim);
        
        
        
        
        
    }

    else {
        
        g.readGraph("saved.txt");
        
    }
    
    time_t start;
    time_t end;

    cout << "Argc : " << argc << endl;
   // g.readGraph();
    
    //   g.printMatrix();
    
//    g.saveMatrix("saved.txt");
    
    
   // g.KargerMinCut();
    
    return 1;
    
    start = time(NULL);
    
   
    MultiGraph * min_cut;
        
    min_cut = new MultiGraph;

    
    MinCutRoot& r = * new ( tbb::task::allocate_root()) MinCutRoot(g, *min_cut);
    
    tbb::task::spawn_root_and_wait(r);
    
    end = time(NULL);
    
    
    
    
    cout << "The Parallel Algorithm finished in " << end - start << " seconds" << endl;
    
    
//    first = &min_cut->contracted[ min_cut->cut_vertices.first ];
//    second = &min_cut->contracted[ min_cut->cut_vertices.second];
//    
//    
//    cout << "The two sets are: " << endl;
//    
//    for( it = first->begin(); it != first->end(); it++) cout << (*it) << " ";
//    
//    cout << endl << endl;;
//    for( it = second->begin(); it != second->end(); it++) cout << (*it) << " " ;
//    
//    start = time(NULL);
    

    
       
    
//    if(!min_cut.edges.empty() ){
//        
//        int v1 = min_cut.edges.front().getSource().getIndex();
//        int v2 = min_cut.edges.front().getDest().getIndex();
//        
//                        
//        std::cout <<   "The minimum cut weight founded is : " << min_cut.min_cut_weight << std::endl;
//        
//        cout << "Number of vertices in the first cut set: " << min_cut.vertices[v1].contracted.size() + 1 << endl;
//        cout << "Number of vertices in the second cut set: " << min_cut.vertices[v2].contracted.size() + 1 << endl;
//        
//    
//    
//    }
//    
//    else cout << "The edge list was empty!! " << endl;
//    
    
    
    
    return 1;
}

